package com.community.backend.mapper;

import com.community.backend.annotation.AutoFill;
import com.community.backend.enumeration.OperationType;
import com.community.backend.pojo.Fee;
import com.community.backend.pojo.dto.FeeQueryDTO;
import com.community.backend.pojo.vo.FeeQueryVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Map;

@Mapper
public interface FeeMapper {
    Page<FeeQueryVO> pageQuery(FeeQueryDTO feeQueryDTO);

    @AutoFill(OperationType.INSERT)
    void insert(Fee fee);
    @AutoFill(OperationType.UPDATE)
    void update(Fee fee);

    @Select("select * from fee where id = #{id} and isDelete = '未删除'")
    Fee selectById(String id);
    @Update("update fee set status = #{status},updateId = '支付宝',updateName='支付宝',updateRole='支付宝',updateTime =#{now} where id = #{id}")
    void updateStatus(String id, String status, LocalDateTime now);
    @Update("update fee set tradeNo = #{tradeNo}, payment = #{payment},buyerId = #{buyerId},gmtPayment = #{gmtPayment},status = #{status},updateId = '支付宝',updateName='支付宝',updateRole='支付宝',updateTime =#{gmtPayment} where id = #{outTradeNo}")
    void updatePayment(String outTradeNo,String tradeNo, String payment, String buyerId, String gmtPayment, String status);

    BigDecimal paidSumByMap(Map map);
    @AutoFill(OperationType.UPDATE)
    void updateById(Fee fee);

    Integer selectAllByStatusAndProject(String status, String project);
}
